---
category: Level 1 — Basic
created: '2020-03-16'
keywords: insertAdjacentHTML
title: Insert given HTML after or before an element
---

## Insert after

Insert `html` after the `ele` element:

```js
ele.insertAdjacentHTML('afterend', html);
```

## Insert before

Insert `html` before the `ele` element:

```js
ele.insertAdjacentHTML('beforebegin', html);
```

## See also

-   [Append to an element](https://phuoc.ng/collection/html-dom/append-to-an-element/)
-   [Insert an element after or before other element](https://phuoc.ng/collection/html-dom/insert-an-element-after-or-before-other-element/)
-   [Prepend to an element](https://phuoc.ng/collection/html-dom/prepend-to-an-element/)
